<?php
/**
 *    @Note:Conventional enterprise stand base class
 *    @author:    Haibo
 *    @time: 2010.11.16
 *    @email:zhonghaibo2@126.com 
 */
require_once(dirname(__FILE__)."/../config.inc.php");
include_once(CFG_LIB_DIR."generic.lib.php");
	
if( !class_exists('mysqldb') )
{
	include_once(CFG_LIB_DIR.'mysqldb.inc.php');
	
}
/*  导入分页数据 */
include_once(CFG_LIB_DIR.'num_page.php');

class Info extends mysqldb
{
    var $cateid;	
	
	function __consatruct(){
	}
	
	 /* 获取关于企业（我们）左边栏二级菜单 */
   function getAboutMenu($cateid)
   {
		$SQL="SELECT * FROM `hy_b_infocategory` where ParentID='$cateid'   order by `SortNum` asc,`InfoCategoryID`  desc ";
        $result=$this->commonQuery($SQL);
	  	 return $result;
   }
   
   function getAbout($cateid){
        $SQL="SELECT * FROM `hy_b_infocategory` where InfoCategoryID='$cateid'   ";
        $result=$this->commonQuery($SQL);
	  	 return $result;
   }
   
   	 /* 获取新闻类别单条信息 */
   function getAboutNews($cateid)
   {
   		$strsql=" UPDATE  `hy_b_info` SET Clicks=Clicks+1 where CateID='$cateid' and Lang='cn' ";
		  $result=$this->commonQuery($strsql);
	   	$SQL="SELECT * FROM `hy_b_info` where CateID='$cateid' and Lang='cn' limit 1 ";
        $result=$this->commonQuery($SQL);
	  	 return $result;
   }
   
     /* 获取新闻单条信息 */
   function getNewsOne($id)
   {
   		$SQL="update  `hy_b_info` set `Clicks`=Clicks+1 where `InfoID`='$id'  ";
		parent::query($SQL);
	  	$SQL="SELECT * FROM `hy_b_info` where InfoID='$id'  ";
        $result=$this->commonQuery($SQL);
	  	return $result[0];
   }
   
        /* 获取新闻多条条信息 */
   function getNewsMore($cateid,$limit)
   {
	   	$SQL="SELECT * FROM `hy_b_info` where CateID='$cateid'  and $limit  ";
        $result=$this->commonQuery($SQL);
	  	return $result;
   }
   

   
   	 /* 获取新闻导航栏信息 */
   function getLinks($cateid)
   {
	   $SQL="SELECT * FROM `hy_b_infocategory` where InfoCategoryID ='$cateid'  order by `SortNum` asc,`InfoCategoryID` desc";
	   $result=$this->commonQuery($SQL);
	   return $result[0][CateName ];
   }
   
      	 /* 获取新闻导航栏信息 */
   function getEnLinks($cateid)
   {
	   $SQL="SELECT `CateNameEn` FROM `hy_b_infocategory` where InfoCategoryID ='$cateid'    order by `SortNum` asc,`InfoCategoryID` desc";
	   $result=$this->commonQuery($SQL);
	   return $result[0][CateNameEn ];
   }
   
   // 获取城市
   function getCity($cateid){
       $SQL="SELECT * FROM `hy_b_city` where ParentID  = ".$cateid;
	   $result=$this->commonQuery($SQL);
	   return $result;
   }
   
   function getCityName($cityid){
       $SQL="SELECT CateName as cityname FROM `hy_b_city` where CityID  = ".$cityid;
	   $result=$this->commonQuery($SQL);
	   return $result[0]['cityname'];
  }
   
   
   function indexPro($cateid,$city,$limit = 5){	
        if($cateid == 8) 
		$SQL=" select * from hy_b_sys_products where ( CateID like '110%'  or CateID like '111%' )  and CityID  = '".$city."' order by SysProductsID DESC LIMIT ".$limit." ";
		else
		$SQL=" select * from hy_b_sys_products where CateID like '".$cateid."%' and CityID  = '".$city."' order by SysProductsID DESC LIMIT ".$limit." ";
		
		$result=$this->commonQuery($SQL);
	   return $result;
  }
  
  
   
   	/* 获得信息列表 */
     function getNewList($infocateid,$pagesize)
  {
		 $countSql="SELECT * FROM hy_b_info  where Lang='cn'  and `CateID`=".$infocateid; //sql语句
		$pageSize=$pagesize; //每页显示数
		$curPage=@$_GET['curPage'];//通过GET传来的当前页数
	   // $urlPara="id=".$id."&cateid=".$cid;//这是URL后面跟的参数，也就是问号传值
		
		$pageOutStr=reterPageStrSam($pageSize,$curPage,$countSql,$urlPara);
		$pageOutStrArr=explode("||",$pageOutStr);
		$rsStart=$pageOutStrArr[0];//limit 后的第一个参数
		$pageStr=$pageOutStrArr[2];//limit 后的第二个参数
		$pageCount=$pageOutStrArr[1];//总页数
		$sql = "select * FROM  hy_b_info where   Lang='cn'  and CateID ='$infocateid' order by InfoID DESC limit $rsStart, $pageSize";
		//echo $sql;
		//$res = mysql_query($sql);
		$objDb = new mysqldb();
		$objDb->query($sql);
		$row1=$objDb->get_data();
		$doublelist=array("page"=>$pageStr,"list"=>$row1);
		return $doublelist;
  }
  
  /**
   * @Note:The following product release system for public methods
   * @Authour:ZhongHaibo
   * @Email:zhonghaibo2@126.com
   * @Time:2010.11.17
   */
   
   	 /* 产品左边栏二级菜单 */
   function getProMenu($cateid)
   {
		$SQL="SELECT * FROM `hy_b_sys_procategory`  where ParentID ='$cateid' order by `SortNum` asc,`SysProCategoryID`  desc ";        		        $result=$this->commonQuery($SQL);
	  	return $result;
   }
   
      	 /* 获取产品导航栏信息 */
   function getProLinks($cateid)
   {
	   $SQL="SELECT * FROM `hy_b_sys_procategory`  where SysProCategoryID = '$cateid' order by `SortNum` asc,`SysProCategoryID`  desc";
	   $result=$this->commonQuery($SQL);
	   return $result[0][CateName];
   }
   
   
      	 /* 获取产品单条信息 */
   function getProOne($pid)
   {
		$SQL="update  `hy_b_sys_products` set `Clicks`=Clicks+1 where `SysProductsID`='".$pid."'";
		parent::query($SQL);
	    $SQL="SELECT * FROM `hy_b_sys_products` where SysProductsID='".$pid."'";
		return  $result=$this->commonQuery($SQL);
   }
   
   
   
      	 /* 获取订购产品单条信息 */
   function getProOrderOne($pid,$limit)
   {
		$SQL="update  `hy_b_sys_products_order` set `Clicks`=Clicks+1 where `SysProductsID`='$pid' limit 0,$limit ";
		parent::query($SQL);
	    $SQL="SELECT * FROM `hy_b_sys_products_order` where SysProductsID='$pid'";
		$result=$this->commonQuery($SQL);
		return $result;
   } 
          /* 获取订购产品多条信息 */
   function getProOrderMore($procateid,$limit)
   {
	   	$SQL="SELECT * FROM `hy_b_sys_products_order` where Lang='cn'  and `CateID`='$procateid' and Unit>0 limit 0, $limit";//sql语句
         $result=$this->commonQuery($SQL);
	  	return $result;
   }
        /* 获取产品多条信息 */
   function getProMore($procateid,$limit)
   {
	   	$SQL="SELECT * FROM `hy_b_sys_products` where Lang='cn'  and `CateID`='$procateid' limit 0, $limit";//sql语句
         $result=$this->commonQuery($SQL);
	  	return $result;
   }
  
  //获取品牌
     function getBland()
   {
	   	$SQL="SELECT * FROM `hy_b_brandcategory` ";//sql语句
         $result=$this->commonQuery($SQL);
	  	return $result;
   }
   

   
   
   //加入购物车
   function addCart($id,$cityid){
        $this->checkIsLogin();
		
		$SQL="SELECT productID FROM `hy_b_car`  where productID = '".$proresult[0]['SysProductsID']."' ";
	    $result=$this->commonQuery($SQL);
	    $thisprid = $result[0][productID];
		
	   	$SQL="select * from hy_b_sys_products where  SysProductsID = ".$id;//sql语句
        $proresult=$this->commonQuery($SQL);
		
		$SQL="SELECT productID FROM `hy_b_car`  where productID = '".$proresult[0]['SysProductsID']."' and  memberID ='".$_SESSION['user_id']."' ";
	    $result=$this->commonQuery($SQL);
	    $thisprid = $result[0][productID];
		$objBase = new clsBase();
		if($thisprid)  $objBase->popup('您的购物车已有该产品了!','index.php?cityid='.$cityid);
		
		$arr  = array(
					    'memberID'    => $_SESSION['user_id'],
						'productID'   => $proresult[0]['SysProductsID'],
						'productName' => $proresult[0]['ProductName'],
						'price'       => $proresult[0]['Price'],
						'buyNum'     => 1,
						'createdate'  => time(),
		         );
	    $table  = "hy_b_car";			 
	    $SQL    = $this->insert($table,$arr);
        $result = $this->commonQuery($SQL);
        
		if(!$result) $objBase->popup('已成功加入购物车');
   }
   
   function delCart(){
	   	$SQL="delete from  hy_b_car where  memberID = ".$_SESSION['user_id'];//sql语句
        $result = parent::query($SQL);
		$objBase = new clsBase();
	    if($result) $objBase->popup('已成功清空购物车');
   }
   
    //申请充值
   function addcj($_POST){
        $this->checkIsLogin();
		  // 加入验证码
	    $this->authcode($_POST['authcode']);
		
		$arr  = array(
			            'orderNum'    => "cz".date('YmdHis').$value['productsID'],
					    'memberID'    => $_SESSION['user_id'],
						'createdate'  => time(),
		         );
		$arr = array_merge ($arr,$_POST);		 
	    $delarr = array('action','authcode','registsubmit','x','y');
	    $table  = "hy_b_cj";	
		$arr = $this->unsetArray($arr,$delarr);		 
	    $SQL    = $this->insert($table,$arr);
        $objBase = new clsBase();
		$result  = parent::query($SQL);
		if($result) $objBase->popup('已成功申请了充值','cjhistory.php'); else 
		 $objBase->popup('申请充值失败','cjhistory.php');
   }
   
   
   //检查积分是否够
   function checkjf($prid){
        $this->checkIsLogin();
        $result = $this->memberMsg();
		$zhifen = $result['zhifen'];
   	    $SQL="select Price from hy_b_sys_products where  SysProductsID = ".$prid;//sql语句
        $proresult=$this->commonQuery($SQL);
		$objBase = new clsBase();
		if($proresult[0]['Price'] >  $zhifen){
		   $objBase->popup('您的积分不够','index.php');
		   exit();
		} 
   
   }
   
   //处理积分产品
   function chulizhifen($prid,$cityid)
   {   
        $this->checkIsLogin($prid);  //检查积分是否足够
		$this->checkjf();
	   	$SQL="select * from hy_b_sys_products where  SysProductsID = ".$prid;//sql语句
        $proresult=$this->commonQuery($SQL);
		
		if($proresult){
		   foreach($proresult as $key=>$value){
				$arr  = array(
								'orderNum'    => date('YmdHis').$value['productsID'],
								'memberID'    => $_SESSION['uid'],
								'productID'   => $value['SysProductsID'],
								'productName' => $value['ProductName'],
								'price'       => $value['Price'],
								'weikuang'    => $_GET['wk'],
								'createdate'  => time(),
								'type'        => 2,  //积分的类型
						 );
				 $arr = array_merge ($arr,$_POST);	
				 $table  = "hy_b_order";			 
				 $delarr = array('user_pws2','authcode','action','DingJin');
		         $arr = $this->unsetArray($arr,$delarr);
				 $SQL    = $this->insert($table,$arr);
				 $result  = parent::query($SQL);
				
				 //扣除虚拟货币
				 $SQL="update  hy_member set zhifen = (zhifen-".$value['Price'].") where  user_id = ".$_SESSION['user_id'];//sql语句
				 parent::query($SQL);
				 
	   		}
	   }
        $objBase = new clsBase();
		if($result){
			$SQL="delete from hy_b_car where  memberID = ".$_SESSION['user_id'];//sql语句
            $result  = parent::query($SQL);
		    $objBase->popup('已成功下单','./') ; 
		} 
		else  $objBase->popup('下单失败，请稍候再操作','./') ;
	     
   }
   
   function delcarts($id){
	    $objBase = new clsBase();
	    $SQL="delete from hy_b_car where  productID = ".$id;//sql语句
        $result  = parent::query($SQL);
		 if($result)
		$objBase->popup('已删除'); 
		else
		$objBase->popup('删除失败'); 
	}
   
   
   //保存订单
   function saveOrder($post,$cityid)
   {   
        
        $this->checkIsLogin();
        $SQL="select sum(`price`) as totalmoney from hy_b_car where  memberID = ".$_SESSION['user_id'];//sql语句
        $result=$this->commonQuery($SQL);
		$totalmoney = $result[0]['totalmoney'];
       
		//扣除虚拟货币
		$result = $this->memberMsg();
		$money = $result['money'];
		if($money < $totalmoney){ 
   		    $objBase = new clsBase();
    		$objBase->popup('虚拟货币不够，请充值！','./cz1.php?cityid='.$cityid) ;
		    exit();
		} else {
			$SQL="select * from hy_b_car where  memberID = ".$_SESSION['user_id'];//sql语句
			$proresult=$this->commonQuery($SQL);
			if($proresult){
			   foreach($proresult as $key=>$value){
				   $prids [] = $value['productID'];
				   
				   $SQL=" select num from  hy_b_sys_products where    SysProductsID  = ".$value['productID'];//sql语句
				   $result=$this->commonQuery($SQL);
				   $thisnum = $result[0]['num'];
				   $objBase = new clsBase();
				   $str ='该商品'.$value['productName'].'已经给人购买了！';
				   
				   if(empty($thisnum)) 	$objBase->popup($str,'cart.php?cityid='.$cityid) ;
				   
				   $productID[]  = $value['productID'];
				   $productName[] = $value['productName'];
				   $buyNum[] = $value['buyNum'];
				   $price[] = $value['price'];
				     
			   }
			 }
		
			if($productID) $productID = implode(',',$productID);
			if($productName) $productName = implode(',',$productName);		
			if($buyNum)   $buyNum = implode(',',$buyNum);		
			if($price){   
			    $TotalPrice5 = @array_sum($price);
			    $price = implode(',',$price);	
			}	
			
			$arr  = array(
							'orderNum'    => date('YmdHis').rand(1,100),
							'memberID'    => $_SESSION['user_id'],
							'productID'   => $productID,
							'productName' => $productName,
							'price5' => $price,
							'weikuang'    => $_GET['wk'],
							'state'       => 3,
							'buyNum'      => $buyNum,
							'TotalPrice5' => $TotalPrice5,
							'createdate'  => time(),
					 );
			 $arr = array_merge ($arr,$post);	
			 $table  = "hy_b_order";			 
			 $delarr = array('user_pws2','authcode','action','DingJin','price','TotalPrice');
			 $arr = $this->unsetArray($arr,$delarr);
			 $SQL    = $this->insert($table,$arr);
			 $result  = parent::query($SQL);
		  
		
        $objBase = new clsBase();
		
		//if($_POST['PayType']== 1) echo "<script>location.href='./alipay/index.php?price=".$proresult[0]['DingJin']."&title=购买".$proresult[0]['ProductName']."定金&content=".$_POST['Message']."';<//script>";
		
		if($result){
			 //扣除虚拟货币
			$SQL="update  hy_member set money = (money-$totalmoney ) where  user_id = ".$_SESSION['user_id'];//sql语句
			parent::query($SQL);
			
			if($prids){
				$strprids = implode(',',$prids);
			 	$SQL="update  hy_b_sys_products set num = (num-1 ) where  SysProductsID in (".$strprids.")";//sql语句
				parent::query($SQL);
			}
			$SQL="delete from hy_b_car where  memberID = ".$_SESSION['user_id'];//sql语句
            $result  = parent::query($SQL);
		    $objBase->popup('已成功下单','./memberorder.php?cityid='.$cityid) ; 
		} 
		else  $objBase->popup('下单失败，请稍候再操作','index.php?cityid='.$cityid) ;
	     
       }
   }
   
   //会员登陆
   function memberlogin($post){
	    $SQL    = "select * from hy_member where  user_name ='".$post['username']."' and user_pws = '".$post['password']."' ";
        $member = $this->commonQuery($SQL);
		$objBase = new clsBase();
	
		if($member[0]['auto'] == 0) {
			 $objBase->popup('账号未审核！','login.php'); 
			 exit();
		}else if($member[0]['auto'] == 2) {
			 $objBase->popup('账号审核不通过！','login.php'); 
			 exit();
		}
		
		if($member){ 
  		   $_SESSION['user_id']   = $member[0]['user_id'];
		   $_SESSION['user_name'] = $member[0]['user_name'];
		   
		   //加积分
		   $this->addZhifen(1);
		   
		   $objBase->popup('您好，'.$post['username'].'，欢迎回来！','index.php' );
		} else {
		   $objBase->popup('账号或密码错误！','login.php');
		}
   }
   
   //检查是否登陆
   function checkIsLogin(){
     $objBase = new clsBase();
     if(empty($_SESSION['user_id']))   $objBase->popup('对不起，只有我们的会员才能享受该服务，请登陆！',"./");
   }
   
   function suretorecive($id){
	    $SQL    = "update hy_b_order  set `state` =5  where  id = '".$id."' ";
        $result  = parent::query($SQL);
	    $objBase = new clsBase();
        if($result)   $objBase->popup('确认成功！');
	  }
   
   //加积分
   function addZhifen($num){
       $SQL    = "update hy_member set `zhifen` = (`zhifen`+ ".$num.") where  user_id = '".$_SESSION['user_id']."' ";
       $member = $this->commonQuery($SQL);
   }
   
   //获取会员资料
   function memberMsg(){
       $SQL  = "select * from hy_member where  user_id = '".$_SESSION['user_id']."'";
       $result = $this->commonQuery($SQL);
	   return $result[0];
   }
   //获取会员头像
   function getIcon($uid){
       $SQL  = "select user_icon from hy_member where  user_id = '".$uid."'";
       $result = $this->commonQuery($SQL);
	   return $result[0]['user_icon'];
   }
   
      
   //修改会员头像
    function setIcon($user_icon)
   {
	   	$SQL=" update hy_member set user_icon = '".$user_icon."' where user_id='".$_SESSION['user_id']."'";
	
        $result=$this->commonQuery($SQL);
	  	return $result;
   }
   
   //获得购物车数量
   function getCartNum(){
    	$SQL=" select count(*)  as num from hy_b_car  where memberID='".$_SESSION['user_id']."'";
        $result = $this->commonQuery($SQL);
	  	return $result[0]['num'];
   }
   
   
   //获得购物车
   function getCartList(){
    	$SQL=" select *  from hy_b_car  where memberID='".$_SESSION['user_id']."'";
        $result = $this->commonQuery($SQL);
	  	return $result;
   }
   
   
   function usereg($post){
	    // 加入验证码
	    $this->authcode($post['authcode']);
	    $arr  = $post;
	    $arr['user_regtime']  =  date('Y-m-d H:i:s',time());
	    $table   = "hy_member";			 
		$delarr  = array('user_pws2','authcode','action','x','y');
		$arr     = $this->unsetArray($arr,$delarr);
		$sql     = $this->insert($table,$arr);
        $result  = parent::query($sql);
        $objBase = new clsBase();
		if($result) $objBase->popup('成功注册!','login.php'); else  $objBase->popup('注册失败!','login.php'); 
   }
   
   //修改会员资料
   function modifyreg($post){
   	    // 加入验证码
	    $this->authcode($post['authcode']);
	    $arr  = $post;
	    $table  = "hy_member";			 
		$delarr = array('user_pws2','authcode','action');
		$arr = $this->unsetArray($arr,$delarr);
		$wherearr = array('user_id'=>$_SESSION['user_id']);
		$sql = $this->update($arr,$table,$wherearr);
		$result = parent::query($sql);
        $objBase = new clsBase();
		if($result) $objBase->popup('修改成功!','member.php');
   
   }
   
   
   function mobilereg($post){

	  $arr  = array(
		                'user_tel'    => $post['mobileInfo'],
					    'user_pws'     => $post['pwd2'],
						'user_regtime' => date('Y-m-d H:i:s',time()),
		         );
	    $table  = "hy_member";			 
	    $SQL    = $this->insert($table,$arr);
        $result = $this->commonQuery($SQL);
        $objBase = new clsBase();
		if(!$result) $objBase->popup('成功注册!','login.php');
   }
   
   
   function emailreg($post){
	  // 加入验证码
	 $this->authcode($post['authcode']);
	  
	  $arr  = array(
		                 'user_email'   => $post['mail'],
					    'user_pws'     => $post['pwd2'],
						'user_regtime' => date('Y-m-d H:i:s',time()),
		         );
	    $table  = "hy_member";			 
	    $SQL    = $this->insert($table,$arr);
        $result = $this->commonQuery($SQL);
        $objBase = new clsBase();
		if(!$result) $objBase->popup('成功注册!','login.php');
   }
   
   //验证码
   function authcode($authcode){
       $objBase = new clsBase();
       if($_SESSION['seccode'] == "" || trim($authcode) != $_SESSION['seccode']){
		$objBase->popup('验证码错误!');
		exit;
	  }
   }
   
   
   //修改会员密码
   function modifypsw($arr){
       $objBase = new clsBase();
	   $oldpsw = $arr['oldpsw'];
	   $repassword = $arr['repassword'];
	   $delarr = array('action','authcode','user_pws2','oldpsw');
	   $arr = $this->unsetArray($arr,$delarr);
	   
      //查找旧密码是否正确
	   if($oldpsw){
		  $SQL  = "select * from hy_member where  user_id = '".$_SESSION['user_id']."' and user_pws = '".$oldpsw."'";
		   $result = $this->commonQuery($SQL);
		   if(!$result){   
			  $objBase->popup('旧密码不正确!','memberpsw.php'); 
			  die;
		   } else {
				$arr['user_pws'] = $repassword;
		   }  
      }
	 
	  $table = "hy_member";
	  $wherearr = array('user_id'=>$_SESSION['user_id']);
	  $sql = $this->update($arr,$table,$wherearr);die;
	  $result=$this->commonQuery($sql);
	
      $objBase->popup('修改成功!','member.php');
   }
   
   
   //会员退出
   function memberexit(){
      session_destroy();
	  $objBase = new clsBase();
      $objBase->popup('您好，您已安全退出！','login.php' );
   }
   
  
  //首页产品
   function getIndexPro($limit)
   {
	   	$SQL="select * from hy_b_sys_products where 1 order by SysProductsID DESC LIMIT $limit ";//sql语句
        $result=$this->commonQuery($SQL);
	  	return $result;
   }
  
  
	   //获得产品列表
	  function getProductList($procateid){
	 			
             $countSql="SELECT * FROM  `hy_b_sys_products` where Lang='cn'  and `CateID`=".$procateid;//sql语句
            $pageSize="12"; //每页显示数
            $curPage=@$_GET['curPage'];//通过GET传来的当前页数
           // $urlPara="id=".$id."&cid=".$cid;//这是URL后面跟的参数，也就是问号传值
            $pageOutStr=reterPageStrSam($pageSize,$curPage,$countSql,$urlPara);
            $pageOutStrArr=explode("||",$pageOutStr);
            $rsStart=$pageOutStrArr[0];//limit 后的第一个参数
            $pageStr=$pageOutStrArr[2];//limit 后的第二个参数
            $pageCount=$pageOutStrArr[1];//总页数
            $sql = "SELECT * FROM  hy_b_sys_products  where   Lang='cn'  and `CateID` ='$procateid' order by SysProductsID DESC limit $rsStart, $pageSize";
            //$res = mysql_query($sql);
			$objDb = new mysqldb();
            $objDb->query($sql);
            $row1=$objDb->get_data();
			$doublelist=array("page"=>$pageStr,"list"=>$row1);
			return $doublelist;
	  }
	  
	  function getcateintro($cateid){
			$SQL="SELECT * FROM `hy_b_infocategory` where InfoCategoryID = '$cateid'  ";
			$objDb = new mysqldb();
			$objDb->query($SQL);
			$result = $objDb->get_data();
			return  $result[0]['Intro'];
		}
	  
	  	   //获得预订产品列表
	  function getProductOrderList($procateid){
	 			
             $countSql="SELECT * FROM  `hy_b_sys_products_order` where Lang='cn' and Unit>0  and `CateID`=".$procateid;//sql语句
            $pageSize="12"; //每页显示数
            $curPage=@$_GET['curPage'];//通过GET传来的当前页数
           // $urlPara="id=".$id."&cid=".$cid;//这是URL后面跟的参数，也就是问号传值
            
            $pageOutStr=reterPageStrSam($pageSize,$curPage,$countSql,$urlPara);
            $pageOutStrArr=explode("||",$pageOutStr);
            $rsStart=$pageOutStrArr[0];//limit 后的第一个参数
            $pageStr=$pageOutStrArr[2];//limit 后的第二个参数
            $pageCount=$pageOutStrArr[1];//总页数
            $sql = "SELECT * FROM  hy_b_sys_products_order  where   Lang='cn' and Unit>0  and `CateID` ='$procateid' order by SysProductsID DESC limit $rsStart, $pageSize";
            //$res = mysql_query($sql);
			$objDb = new mysqldb();
            $objDb->query($sql);
            $row1=$objDb->get_data();
			$doublelist=array("page"=>$pageStr,"list"=>$row1);
			return $doublelist;
	  }
	  

	  //获取产品订购量
     function getProOrderNum($prid)
     {
	   	$SQL="select count(*) as num from hy_b_order where  productID =  ".$prid;//sql语句
        $result=$this->commonQuery($SQL);
	  	return $result[0]['num'];
     }
  

	 //=====================================================================================================================================================================================================================================================================================================================================================================================================================/ 
		   /**
	 * 
	 * 发送邮件端
	 */
     function mail(){
		$member['email'] = $this->member_model->getEmails();
		$name       = $this->input->post('name');     //
		$title      = $this->input->post('title');     //
		$content    = $this->input->post('content');     //
		
		$arr = array(
		  'name' => $name,
		  'title' =>$title,
		  'content'=>$content,
		);
		
		$curlPost      = $this->handleUrl($arr);
		if(!empty($name) ){
		    $url = "http://www.4007798866.com//php-email/";
		    
	    	$ch   = curl_init();                                 //初始化curl  
		    curl_setopt($ch, CURLOPT_URL, $url);                          //提交到指定网页  
		    curl_setopt($ch, CURLOPT_HEADER, 0);                          //设置header  
		    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);                  //要求结果为字符串且输出到屏幕上  
		    curl_setopt($ch, CURLOPT_POST, 1);                            //post提交方式  
		    curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost); 
		    $data = curl_exec($ch);                                       //运行curl  
		    curl_close($ch); 
			
			$arr = $this->manageData($data);
			if($arr['b'] == "200"){
				$this->popup('successfully');
				exit();
			} else {
				$this->popup('send_failed');
				exit();
			} 
		}
		
		$this->load->view('admin/header_view', $this->data);
		$this->load->view('admin/mail',$member);
		$this->load->view('admin/footer_view');
	}
	
 
	
	/**
	 * 
	 * 发送 短信端
	 * @param String $tel  
	 * @param Int $sms
	 */
    public function actionDuanxin($tel,$sms){
		
		$arr = array(
		  'username' => USERNAME,  //用户名
		  'Password' => PASSWORD,  //用户密码
		  'tel'      => $tel,      //发送目标号码（多个号码以”|”分隔，单次提交号码不得超过1W条，例：1376462XXXX|1376462XXXX|1376462XXXX）
		  'sms'      => $sms,      //短信内容（内容不能超过70个字符）
		);
		
	    $curlPost      = $this->handleUrl($arr);
	
		if(!empty($name) ){
		    $url = "http://218.242.44.53:9999/sendsms.aspx";
	    	$ch = curl_init();                                 //初始化curl  
		    curl_setopt($ch, CURLOPT_URL, $url);               //提交到指定网页  
		    curl_setopt($ch, CURLOPT_HEADER, 0);               //设置header  
		    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);       //要求结果为字符串且输出到屏幕上  
		    curl_setopt($ch, CURLOPT_POST, 1);                 //post提交方式  
		    curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost); 
		    $data = curl_exec($ch);                            //运行curl  
		    curl_close($ch); 
			
		 	 $msgArr = array(
		    	'0'   =>'成功',
		        '-1'  =>'失败',
		        '-2'  =>'缺少目标号码',
		        '-3'  =>'缺少用户名或密码', 
		    	'-4'  =>'缺少短信内容',
		        '-5'  =>'登陆失败',
		        '-6'  =>'存在非法字符',
		        '-7'  =>'存在错误号码', 
		    	'-8'  =>'余额不足',
		        '-9'  =>'服务器连接失败',
		        '-10' =>'服务器连接失败',
		        '-11' =>'短信内容存在系统保留关键词',
		        '-12' =>'号码条数超出限制',
		        '-13' =>'短信内容长度超出', 
		    );
		    
		    foreach ($msgArr as $key=>$value){
		      if($key == $data){
		    		$this->popup($value);
		    	}
		    }
		}
	}
	
	
	   /**
	 * curl处理返回结果字符串
	 * @param String $arr
	 * @return Array $arr
	 */
	function manageData($str){
		$arr = explode('&',$str);
	    if($arr){
		    foreach ($arr  as $value) {
		    	$secarr = explode("=", $value);
		    	$newarr[$secarr[0]] =$secarr[1]; 
		    }
	    }
	    return $newarr;
   }

   
    /* 本类中公共调用的查询语句方法*/
   function commonQuery($SQL)
   { 
   		parent::query($SQL);
		$result = parent::get_data();
        if($result)
		{
		   return  $result;
        }
		else
		{
            // echo "没有内容！";
			//var_dump($result);
        }
   
   }
   
    /***
 	 * 处理URL字符串
 	 * @arr Array $arr
 	 * @return Array $str
 	 */
 	public function handleUrl($arr = array()){
 	   $str = '';
 	   if($arr){
 	   	  foreach($arr as $key => $value){
 	   	  	 $str[] = $key.'='.$value;
 	   	  }
 	   }
 	   $str =  implode("&", $str);
 	   return $str;
 	}
   
    function getFuHao($i,$arr,$fuhao)
   {
     if($i==sizeof($arr)-1) $douhao="";
	 else  $douhao=$fuhao;	
	 return $douhao;
   }
   
   
   /**
 	 * 
 	 * 删除不需要的数组
 	 * @param Array $array
 	 * @param Array $delarr
 	 */
	public function unsetArray($array,$delarr){
		foreach ($array as $bkey=>$bvalue){
			foreach ($delarr as $key=>$value){
				if($value == $bkey){
				unset($array[$bkey]);		
			    }
		     }
	    }
		return $array;
	}
   
    function insert($table,$ars){
	     if($ars){
			foreach($ars as $key=>$value){
				if($x==sizeof($ars)-1) $douhao="";else $douhao=",";	
				$mm.="`".$key."`".$douhao;	
				$nn.="'".$value."'".$douhao;		
				if($x==sizeof($ars)-1){
					 break;
				} else {
				  $x++;
				}
			}	
			
			$sql="insert into $table ($mm)values($nn)";
			if($state==1) echo $sql;
			if($state==0) echo "";
			return $sql;
			}
			
	}
	
	
	/*
	向数据库更新符合要求的所有数据,如果成功返回true,否则返回false,参数1是要跟新的字段=>值数组，参数3是where子句数组
	*/
	function update($arr,$table,$where){
		$str="UPDATE `$table` SET ";
		foreach ($arr as $key=>$value){
			$str_key.="`".$key."`='".$value."',";
		}
		$str_key=substr($str_key,0,-1);
		foreach ($where as $key=>$value){
			$sql_where.="`$key`"."='".$value."' AND";
		}
		$sql_where=substr($sql_where,0,-4);
		return $sql_update=$str.$str_key." WHERE ".$sql_where.";";
		
	}
}